package com.lyf.design.learn.effectivejava.object;

import org.junit.Test;

import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Collections;

/**
 * 原则1：
 * 考虑采用静态工厂代替构造器
 * 优势：
 * 1.它们有名称，直接通过参数构造对象，易记错
 * 2.不必每次调用时都创建一个对象
 *
 *
 * @author LYF
 * @date 2022/6/28
 */
public class StaticFactory {
    /*
    1.源码参考
    （1）JDK-- Boolean+Collections
    (2)JDBC - Driver的加载-- 服务调用框架-- 优势三
     */
    @Test
    public void test1() throws SQLException {
        /*
        public static final Boolean TRUE = new Boolean(true);
        public static final Boolean FALSE = new Boolean(false);
            @IntrinsicCandidate
        public static Boolean valueOf(boolean b) {
            return (b ? TRUE : FALSE);
        }
         */
        Boolean b = Boolean.valueOf(false);

        /*
            public static <T> List<T> synchronizedList(List<T> list) {
        return (list instanceof RandomAccess ?
                new SynchronizedRandomAccessList<>(list) :
                new SynchronizedList<>(list));
    }
         */
        //Collections

        DriverManager.deregisterDriver(DriverManager.getDriver(""));
    }



}
